﻿using System.Windows;
#if NETFX_CORE
using Windows.UI.Xaml;
using Windows.UI.Xaml.Data;
#else
using System.Windows.Data;
#endif
using MugenMvvmToolkit.Converters;

namespace MugenMvvmToolkit.Bindings
{
    /// <summary>
    ///     This converts a Boolean to a Visibility. False to Visibility.Collapsed, true to Visibility.Visible.
    /// </summary>
    public sealed class FalseToCollapsedBinding : Binding
    {
        #region Fields

        private static readonly BooleanToVisibilityConverter VisibilityConverter = new BooleanToVisibilityConverter
                                                                              {
                                                                                  TrueValue = Visibility.Visible,
                                                                                  FalseValue = Visibility.Collapsed
                                                                              };

        #endregion

        #region Constructors

        /// <summary>
        /// Initializes a new instance of the <see cref="FalseToCollapsedBinding"/> class.
        /// </summary>
        public FalseToCollapsedBinding()
        {
            Converter = VisibilityConverter;
        }

#if !NETFX_CORE
        /// <summary>
        /// Initializes a new instance of the <see cref="FalseToCollapsedBinding"/> class with an initial path.
        /// </summary>
        /// <param name="path">The initial <see cref="P:System.Windows.Data.Binding.Path"/> for the binding.
        ///                 </param>
        public FalseToCollapsedBinding(string path)
            : base(path)
        {
            Converter = VisibilityConverter;
        }
#endif
        #endregion
    }

    /// <summary>
    ///     This converts a Boolean to a Visibility. False to Visibility.Visible, true to Visibility.Collapsed.
    /// </summary>
    public sealed class TrueToCollapsedBinding : Binding
    {
        #region Fields

        private static readonly BooleanToVisibilityConverter VisibilityConverter = new BooleanToVisibilityConverter
        {
            TrueValue =
                Visibility.Collapsed,
            FalseValue =
                Visibility.Visible
        };

        #endregion

        #region Constructors

        /// <summary>
        /// Initializes a new instance of the <see cref="TrueToCollapsedBinding"/> class.
        /// </summary>
        public TrueToCollapsedBinding()
        {
            Converter = VisibilityConverter;
        }

#if !NETFX_CORE
        /// <summary>
        /// Initializes a new instance of the <see cref="TrueToCollapsedBinding"/> class with an initial path.
        /// </summary>
        /// <param name="path">The initial <see cref="P:System.Windows.Data.Binding.Path"/> for the binding.
        ///                 </param>
        public TrueToCollapsedBinding(string path)
            : base(path)
        {
            Converter = VisibilityConverter;
        }
#endif
        #endregion
    }    

#if WPF
    /// <summary>
    ///     This converts a Boolean to a Visibility. False to Visibility.Visible, true to Visibility.Hidden.
    /// </summary>
    public sealed class TrueToHiddenBinding : Binding
    {
        #region Fields

        private static readonly BooleanToVisibilityConverter VisibilityConverter = new BooleanToVisibilityConverter
        {
            TrueValue =
                Visibility.Hidden,
            FalseValue =
                Visibility.Visible
        };

        #endregion

        #region Constructors

        /// <summary>
        /// Initializes a new instance of the <see cref="TrueToHiddenBinding"/> class.
        /// </summary>
        public TrueToHiddenBinding()
        {
            Converter = VisibilityConverter;
        }

#if !NETFX_CORE
        /// <summary>
        /// Initializes a new instance of the <see cref="TrueToHiddenBinding"/> class with an initial path.
        /// </summary>
        /// <param name="path">The initial <see cref="P:System.Windows.Data.Binding.Path"/> for the binding.
        ///                 </param>
        public TrueToHiddenBinding(string path)
            : base(path)
        {
            Converter = VisibilityConverter;
        }
#endif
        #endregion
    }

    /// <summary>
    ///     This converts a Boolean to a Visibility. False to Visibility.Hidden, true to Visibility.Visible.
    /// </summary>
    public sealed class FalseToHiddenBinding : Binding
    {
        #region Fields

        private static readonly BooleanToVisibilityConverter VisibilityConverter = new BooleanToVisibilityConverter
        {
            TrueValue =
                Visibility.Visible,
            FalseValue =
                Visibility.Hidden
        };

        #endregion

        #region Constructors

        /// <summary>
        /// Initializes a new instance of the <see cref="FalseToHiddenBinding"/> class.
        /// </summary>
        public FalseToHiddenBinding()
        {
            Converter = VisibilityConverter;
        }

#if !NETFX_CORE
        /// <summary>
        /// Initializes a new instance of the <see cref="FalseToHiddenBinding"/> class with an initial path.
        /// </summary>
        /// <param name="path">The initial <see cref="P:System.Windows.Data.Binding.Path"/> for the binding.
        ///                 </param>
        public FalseToHiddenBinding(string path)
            : base(path)
        {
            Converter = VisibilityConverter;
        }
#endif
        #endregion
    }
#endif

}
